<template>
	<view class="page">
		<view style="background: #fff;">
			<u-cell-item title="添加商品" @click="add"></u-cell-item>
		</view>


		<view  style="background: #fff;padding: 30rpx;" v-for="(item,index) in list " :key="index" class="u-border-bottom u-flex">
			<view>
				<u-image :src="item.cover" width="200" height="200" border-radius="30"></u-image>
			</view>
			<view class="u-margin-left-20 " style="width: 500rpx; height: 200rpx; display: flex;justify-content: space-between;flex-direction: column;">
				<view class="u-line-2 u-font-weight" style="">
					{{item.goodsName}}
				</view>
				<view class="u-flex"  >
					<view class="u-type-error">
						￥{{item.price}}
					</view>
					<view class="u-margin-left-20 u-flex  u-row-between " style="width: 320rpx; ">
						<u-button size="mini"  @click="goodsChange(item)" type="success" v-if="!item.status" shape="circle">上架</u-button>
						<u-button size="mini" @click="goodsChange(item)" type="primary" v-else shape="circle">下架</u-button>
						<u-button size="mini"  @click="edit(item)"  type="warning" shape="circle">修改</u-button>
						<u-button size="mini"  @click="del(item)"  type="error" shape="circle">删除</u-button>
					</view>
				</view>
			</view>



		</view>

	</view>
</template>

<script>
	import loader from '@/common/loadPage.js';
	export default {
		mixins: [loader],
		data() {

			return {
				tabbar: [],
				nav: [],
				current: 0,
				list: [],
				initial: {
					geturl: "/user/goods",
					parm: {

					},
					isPage: true
				},




			}
		},
		async onLoad() {

			
		},
		onShow() {
			this.getGoods()
		},
		methods: {
			
			goodsChange(item){
				this.$u.post('/user/goodsChange', {
					id:item.id
				}).then(res => {
					this.getGoods()
				}).catch(err => {
				      
				      							
				})
			
			
			},
			del(item){
				this.$u.post('/user/goodsDel', {
					id:item.id
				}).then(res => {
					this.getGoods()
				}).catch(err => {
				      
				      							
				})
							
			},
			edit(item){
				uni.navigateTo({
					url: './add?id='+item.id
				})
			},
			add() {
				uni.navigateTo({
					url: './add'
				})
			},
			
			
			

		}
	}
</script>


<style>
	.page {
		background: #F1F1F1;
		min-height: 100vh;
	}

	.list {
		background: #fff;
		width: 700rpx;
		margin: 20rpx auto;
		padding: 20rpx;
	}
</style>
